package demo;

/**
 * t4
 */
public class TestEmployee_t5 {
    public static void main(String[] args) {

        Employee_t5 e=new SalesEmployee_t5(1,"销售员",4000d,1000d);
        Employee_t5 e1=new Manager(1,"主管",6000d,2000d);
        double monthlyPay = e.getMonthlyPay();
        double monthlyPay1 = e1.getMonthlyPay();
        System.out.println("销售员："+monthlyPay+",主管："+monthlyPay1);



    }


}

abstract class Employee_t5{
    int id;
    String name;
    Double salary;

    Employee_t5(){}

    public Employee_t5(int id, String name,Double salary) {
        this.id = id;
        this.name = name;
        this.salary=salary;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Double getSalary() {
        return salary;
    }

    public void setSalary(Double salary) {
        this.salary = salary;
    }

    @Override
    public String toString() {
        return "Employee{" +
                "id=" + id +
                ", name='" + name + '\'' +
                '}';
    }

    int compareTo(Object o){
        if(o instanceof Employee){
            Employee o1=(Employee)o;
            return this.id-o1.getId();
        }
        return 0;
    }

    abstract double getMonthlyPay();

}

class SalesEmployee_t5 extends Employee_t5{
    private double proFit;

    public SalesEmployee_t5(int id, String name, Double salary, double proFit) {
        super(id, name, salary);
        this.proFit = proFit;
    }

    public double getProFit() {
        return proFit;
    }

    public void setProFit(double proFit) {
        this.proFit = proFit;
    }

    @Override
    public String toString() {
        return "SalesEmployee{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", salary=" + salary +
                ", proFit=" + proFit +
                '}';
    }

    @Override
    double getMonthlyPay() {
        return this.salary+(this.proFit * 20/100);
    }
}

class Manager extends Employee_t5{
    private double Bunus;

    public Manager(double bunus) {
        Bunus = bunus;
    }

    public Manager(int id, String name, Double salary, double bunus) {
        super(id, name, salary);
        Bunus = bunus;
    }

    @Override
    public String toString() {
        return "Manager{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", salary=" + salary +
                ", Bunus=" + Bunus +
                '}';
    }

    @Override
    double getMonthlyPay() {
        return this.salary+this.Bunus;
    }
}